﻿/*-------------------------------------
//
//Copyright (C) 2007 开发二组 版权所有。
//
//文件名：UserControl_SeracheOrder.cs
//
//
//文件功能描述：对订单的查询.输入订单号查询订单的状态..
//
//
//创建标识：2007.11.19 王志平
//创建描述：
//
//------------------------------------*/
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class UserControl_SeracheOrder : System.Web.UI.UserControl
{

    DataSet myDataSet = new DataSet(); 
    localhost.DocumentService documentSearch = new localhost.DocumentService();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Panel1.Visible = false;
            Panel2.Visible = false;
           
        }
    }
    /// <summary>
    /// 输入订单号码对订单进行查询..
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    void documentSearch_GetOrderListCompleted(object sender, localhost.GetOrderListCompletedEventArgs e)
    {
        //throw new Exception("The method or operation is not implemented.");
        try
        {
            //将异步调用的结果放入到myDataSet中
            myDataSet = e.Result;
            //若订单存在将订单的信息绑定..
            if (myDataSet.Tables[0].Rows.Count > 0)
            { 
                //默认未收到款
                bool isReceiveMoney = false;
                //默许未发货..
                bool isSendGood = false;
                //表中有数据,此时放表的面板显示..
                Panel1.Visible = true;
                //将订单号绑定.
                lblOrderNum.Text = myDataSet.Tables[0].Rows[0]["OrderInfoID"].ToString();
                //将下订单的时间绑定.
                lblOrderTime.Text = myDataSet.Tables[0].Rows[0]["CreationTime"].ToString();
                //是否已收到款绑定.
                isReceiveMoney = Convert.ToBoolean(myDataSet.Tables[0].Rows[0]["PaymentStatus"]);
                if (isReceiveMoney == true)
                {
                    lblIsReceiveMoney.Text = "已收款";
                }
                else
                {
                    lblIsReceiveMoney.Text = "未收到款";
                }
                //将是否已发货绑定..
                isSendGood= Convert.ToBoolean(myDataSet.Tables[0].Rows[0]["ConsignmentStatus"]);
                if (isSendGood == true)
                {
                    lblIsSendGood.Text = "已发货";
                }
                else
                {
                    lblIsSendGood.Text = "未发货";
                }
                this.Panel2.Visible = false;
                this.Panel1.Visible = true;
            }
            else
            {
                this.Panel1.Visible = false;
                this.Panel2.Visible = true;
            }
        }
        //异常处理..
        catch (Exception e1)
        {
            Response.Redirect("Msg.aspx?msg=" + e1.Message);
        }

    }
    /// <summary>
    /// 点击查询,在客户端将对订单在状态进行显示..
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        //
        //当用户没有输入订单号对订单进行查询时,显示为空
        //
        if (this.txtOrderNum.Text==string.Empty)
        {
            Panel1.Visible = false;
            Panel2.Visible = true;
        }
        //
        //当用户输入一个正确的订单号
        //
        else
        {
            //调用异步方法..
            documentSearch.GetOrderListCompleted += new localhost.GetOrderListCompletedEventHandler(documentSearch_GetOrderListCompleted);
            documentSearch.GetOrderListAsync(this.txtOrderNum.Text);
        }
    }

}
